import { BaseModel, sequelize, Sequelize } from "./basemodel.js";

class SmartContracts extends BaseModel {
	static init() {
		return super.init(
			{
				
				id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
				contract_name: { type:Sequelize.STRING , allowNull: false ,defaultValue: Sequelize.literal('DEFAULT') },
				contract_address: { type:Sequelize.STRING , allowNull: false ,defaultValue: Sequelize.literal('DEFAULT') },
				version: { type:Sequelize.STRING , allowNull: false ,defaultValue: Sequelize.literal('DEFAULT') },
				category: { type:Sequelize.ENUM('data','operation','proxy') , allowNull: false ,defaultValue: Sequelize.literal('DEFAULT') },
				description: { type:Sequelize.STRING  ,defaultValue: Sequelize.literal('DEFAULT') },
				creator_address: { type:Sequelize.STRING  ,defaultValue: Sequelize.literal('DEFAULT') },
				path: { type:Sequelize.STRING  ,defaultValue: Sequelize.literal('DEFAULT') },
				storage_address: { type:Sequelize.STRING  ,defaultValue: Sequelize.literal('DEFAULT') },
				date_created: { type:Sequelize.DATE   },
				date_updated: { type:Sequelize.DATE   }
			}, 
			{ 
				sequelize,
				
				tableName: "smart_contracts",
				modelName: "smart_contracts",timestamps:true,
				createdAt: 'date_updated',updatedAt: 'date_created',
				
			}
		);
	}
	
	static listFields() {
		return [
			'id', 
			'contract_name', 
			'contract_address', 
			'version', 
			'category', 
			'description', 
			'creator_address', 
			'path', 
			'storage_address',
			'date_created', 
			'date_updated'
		];
	}

	static viewFields() {
		return [
			'id', 
			'contract_name', 
			'contract_address', 
			'version', 
			'category', 
			'description', 
			'creator_address', 
			'path', 
			'storage_address',
			'date_created', 
			'date_updated'
		];
	}

	static editFields() {
		return [
			'id', 
			'contract_name', 
			'contract_address', 
			'version', 
			'category', 
			'description', 
			'creator_address', 
			'path',
			'storage_address'
		];
	}

	
	static searchFields(){
		return [
			Sequelize.literal("id LIKE :search"), 
			Sequelize.literal("contract_name LIKE :search"), 
			Sequelize.literal("contract_address LIKE :search"), 
			Sequelize.literal("version LIKE :search"), 
			Sequelize.literal("description LIKE :search"), 
			Sequelize.literal("creator_address LIKE :search"), 
			Sequelize.literal("path LIKE :search"),
		];
	}

	
	
}
SmartContracts.init();
export default SmartContracts;
